package com.ww.springboot.boot.javabase.list;

import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.TreeBidiMap;

/**
 * 描述：map双向查询 根据value查key
 *
 * @author 🧑 ‍wanwei
 * @since 2022-12-06 17:09
 */
public class BidiMapDemo {

    public static void main(String[] args) {

        //无论key 或 value 重复都会覆盖旧值 ->先删掉重复的值 再插入新值
        BidiMap bidiMap = new TreeBidiMap();
        bidiMap.put("d","4");
        bidiMap.put("a","1");
        bidiMap.put("b","2");
        bidiMap.put("c","3");


        System.out.println(bidiMap);

        System.out.println(bidiMap.get("a"));
        System.out.println(bidiMap.getKey("2"));

    }
}
